package com.sun.officeoa.service;

import com.sun.officeoa.bean.Employee;
import com.sun.officeoa.bean.Meeting;
import com.sun.officeoa.bean.MeetingRoom;
import com.sun.officeoa.dao.EmployeeDao;
import com.sun.officeoa.dao.MeetingDao;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by sang on 2017/8/21.
 */
@Service
public class MeetingService {

    @Resource
    private MeetingDao meetingDao;

    @Resource
    private EmployeeDao employeeDao ;

    private List<Employee> employeeList;

    public List<Employee> getEmployeeList() {
        return employeeList;
    }

    public List<Meeting> getCanceledMeeting(int empid) {
        return meetingDao.getCanceledMeeting(empid);
    }
    public List<Meeting> getMeeting7Days(int empid) {
        return meetingDao.getMeeting7Days(empid);
    }

    public Meeting getMeetingDetailsByMeetingId (int meeting){
        Meeting me = meetingDao.getMeetingById(meeting);
        this.employeeList = employeeDao.getEmpByMeetingId(me.getMeetingid());
        return me;
    }

    public List<Meeting> getMyBookingMeeting(int loginEmployId){
        return meetingDao.getMyBookingMeeting(loginEmployId);
    }

    public List<Meeting> getMyMeeting(int loginEmployId){
        return meetingDao.getMyMeeting(loginEmployId);
    }

    public int insertMeeting(MeetingRoom meetingRoom){
        return meetingDao.insertMeeting(meetingRoom);
    }

    public int updateMeeting(MeetingRoom meetingRoom){
        return meetingDao.updateMeeting(meetingRoom);
    }

    public List<MeetingRoom> getAllMeetingRoom (){
        return meetingDao.getAllMeetingRoom();
    }

    public MeetingRoom roomdetails(int roomid){
        return meetingDao.roomdetails(roomid);
    }

    public void insert(Meeting meeting, String[] empids) {
        int insert = meetingDao.insert(meeting);
        meetingDao.insertMeetingParticipants(insert, empids);
    }

    public List<Meeting> searchMeeting(String meetingname, String roomname, String reservername, String reservefromdate, String reservetodate, String meetingfromdate, String meetingtodate, int page, int count){
       return  meetingDao.searchMeeting(meetingname,roomname,reservername,reservefromdate,reservetodate,meetingfromdate,meetingtodate,page,count);
    }

    public int  getCount(String meetingname, String roomname, String reservername, String reservefromdate, String reservetodate, String meetingfromdate, String meetingtodate){
        return meetingDao.getCount(meetingname,roomname,reservername,reservefromdate,reservetodate,meetingfromdate,meetingtodate);
    }

}
